package cn.itcast.service.impl;

import cn.itcast.dao.PaylogDao;
import cn.itcast.service.PaylogService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Service
public class PaylogAerviceImpl implements PaylogService {

    @Autowired
    private PaylogDao paylogDao;

    @Override
    public List<Map<String,Object>> findByPrice() {
        return paylogDao.findByPrice();
    }


    @Override
    public List<Integer> findMemberByMonths(List<String> months) {


        List<Integer> dateCount = new ArrayList<>();
        for (String month : months) {
            String max = month+"-31";
            String min = month+"-1";
            int count = this.paylogDao.CouPaylog( max ,min);
            dateCount.add(count);
        }


        return dateCount;
    }
    /**
     * 计算每月支付数量
     * @param months
     * @return
     */
    @Override
    public List<Integer> findByPayStatus(List<String> months) {

        List<Integer> dateCount = new ArrayList<>();
        for (String month : months) {
            String max = month+"-31";
            String min = month+"-1";
            int count = this.paylogDao.findByPayStatus(max,min);
            dateCount.add(count);
        }

        return dateCount;
    }

}
